<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../../vue.js"></script>
  <script src="../../vue-router.js"></script>
  <style>
    .active {
      font-weight: 600;
      color: white;
    }
  </style>
</head>

<body>
  <div id="app">

    <header style="line-height: 60px; background: cornflowerblue;">
      <router-link to="/guide" active-class="active">指南</router-link>
      <router-link to="/api/35" active-class="active">api参考</router-link>
      <router-link to="/updatelist" active-class="active">更新记录</router-link>
    </header>

    <main>
      <router-view></router-view>
    </main>

  </div>


  <script>

    var guide = {
      template: `
      <div style="display:flex;">
        <ul style="width:200px; background:#666; margin:0px; ">
        <router-link tag="li" active-class="active" to="/guide/install">安装</router-link>
        <router-link  tag="li" active-class="active" to="/guide/introduce">介绍</router-link>
        <router-link  tag="li" active-class="active" to="/guide/basic">基础</router-link>
        </ul>
        <router-view style="flex:1; background:#efefef"></router-view>
      </div>
      `
    }

    var routes = [
      {
        path: '/',
        redirect: '/guide/install'
      },
      {
        path: '/guide',
        component: guide,
        children: [
          {
            path: "install",
            component: { template: `<div>install page</div>` }
          },
          {
            path: "introduce",
            component: { template: `<div>introduce page</div>` }
          },
          {
            path: "basic",
            component: { template: `<div>introduce page</div>` }
          }
        ]
      }, {
        path: "/api/:id",
        component: { template: `<div>api page: {{$route.params.id}}</div>` }

      },
      {
        path: "/updatelist",
        component: { template: `<div>updatelist page</div>` }

      }
    ]

    var router = new VueRouter({
      routes
    });

    var vm = new Vue({
      router,
      el: "#app"
    })

  </script>

</body>

</html>